//
// Created by PC on 2024/6/18.
// 查找某数出现的次数(无序数组) 尾递归


#include <iostream>
#include <vector>
using namespace std;

int count_times(vector<int> v, int x, int count= 0, int n= 0)
{
    if(n>=v.size())
        return count;
    if(v[n]==x)
        count++;
    return count_times(v, x, count, n + 1);
}

int main()
{
    //                0   1  2  3  4  5  6  7  8  9  10 11  12
    vector<int> l = {-11, 0, 0, 1, 1, 1, 2, 2, 3, 5, 7, 9, 10};
    int x = 4;
    cout << count_times(l, x);
    return 0;
}